<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button type="primary" v-if="hasPermission('order_hold_confirm')" plain @click="handleHold">订单锁定</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :table-data="tableData" :hasPagination="false" :columns="columns">

    </hey-table>
  </div>
</template>

<script>

  export default {
    name: 'OrderHoldlist',
    components: {

    },
    props: {},
    data() {
      return {
        tableData:[],
        formModel: {
          orderStatus: '03',
          isDelete: '0'
        },
        columns: [
          { title: '上线序列号', key: 'sortNum'},
          { title: '计划编号', key: 'planNo'},
          { title: '订单编号', key: 'orderId'},
          { title: '车辆VIN号', key: 'vin'},
          { title: '订单状态', key: 'orderStatus',clcd:'order_status_cd'},
          { title: '工厂代码', key: 'plantNo'},
          { title: '工厂名称', key: 'plantNameC'},
          { title: '整车物料号', key: 'materialNo'},
          { title: '物料描述', key: 'materialDesc'},
          { title: '车型', key: 'productTypeKey',clcd:'key_product_type'},
          { title: '生产类型', key: 'proType',clcd:'Key_Product_Type'},
          { title: '销售类型', key: 'saleType',clcd:'Key_Sale_Type'},
          { title: '需求类型', key: 'needType',clcd:'need_type_cd'},
          { title: 'VIN年份', key: 'vinYear',clcd:'Key_Vin_ModeYear'},
          { title: '预分配经销商编号', key: 'dealerCode'},
          { title: '计划上线日期', key: 'planStartDate'},
          { title: '计划下线日期', key: 'planEndDate'},
          { title: '实际上线日期', key: 'practicalStartDate'},
          { title: '实际下线日期', key: 'practicalEndDate'},
          { title: '工艺路线代码', key: 'routeNo'},
          { title: '工艺路线名称', key: 'routeName'},
          { title: '上线产线代码', key: 'lineNo'},
          { title: '上线产线名称', key: 'lineNameC'},
          { title: '创建时间', key: 'createTime' },
          { title: '创建人', key: 'createUsername' },
          { title: '更新次数', key: 'updateNum'},
          { title: '最后修改时间', key: 'lastUpdateTime'},
          { title: '最后修改人', key: 'lastUpdateUsername' },
        ],
      }
    },
    computed: {

    },
    mounted() {
      this.queryList()
    },
    methods: {
      handleHold(){
        if(this.tableData.length == 0){
          this.$warn('订单锁定列表中没有数据,不能进行该操作!')
          return false
        }
        const param = {}
        param.vinList = [...this.tableData]
        for(let i=0;i<param.vinList.length;i++){
          if(this.tableData[i].planStartDate){
            param.vinList[i].planStartDate = new Date(this.tableData[i].planStartDate.replace(/-/g,"/"))
          }
          if(this.tableData[i].planEndDate){
            param.vinList[i].planEndDate = new Date(this.tableData[i].planEndDate.replace(/-/g,"/"))
          }
          param.vinList[i].createTime = ''
          param.vinList[i].lastUpdateTime = ''
        }
        const url = '/tmOfmOrder/orderHold'
        this.post(url, param).then(res => {
          var arr = res[0].split("@")
          let str = arr.join(' <br/> ');
          this.$info(str, () => {
            this.queryList()
          })
        })
      },
      queryList() {
        this.formModel.operateType = '13'
        this.$refs.table.query('/tmOfmOrder/queryTmOfmOrderList', this.formModel, '', false)
      },
    }
  }
</script>

<style lang="scss" >

</style>





